<?php

namespace app\api\controller;

use app\BaseController;//测试专用
use think\facade\Db;
use app\api\logic\ApiAdvLogic;
use Throwable;

class ApiAdv extends BaseController
{
    /**
     * 模型
     * @var object
     * @phpstan-var ApiAdvaccountModel
     */

    public function initialize(): void
    {
        parent::initialize();
    }

    /**
     * 获取tiktok广告列表
     * @throws Throwable
     */
    public function GetTiktokAdList()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetTiktokAdList($params);
    }

    /**
     * 获取tiktok广告--历史数据
     * @throws Throwable
     */
    public function GetTiktokAdInfo()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetTiktokAdInfo($params);
    }

    /**
     * 获取tiktok广告--历史数据
     * @throws Throwable
     */
    public function GetFacebookAdStatus()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetFacebookAdStatus($params);
    }
    
    /**
     * 获取tiktok广告--历史数据
     * @throws Throwable
     */
    public function GetFacebookName()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetFacebookName($params);
    }
    /**
     * 获取tiktok广告--历史数据
     * @throws Throwable
     */
    public function GetFacebookAdInfo()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetFacebookAdInfo($params);
    }
    /**
     * 获取tiktok广告--token
     * @throws Throwable
     */
    public function GetFacebookToken()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetFacebookToken($params);
    }

    /**
     * 每天统计广告运营消耗
     * @throws Throwable
     */
    public function DailyStatisticsOfAdv()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->DailyStatisticsOfAdv($params);
    }

    /**
     * 广告转点更新时间
     * @throws Throwable
     */
    public function AdUpdateTime()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->AdUpdateTime($params);
    }
    /**
     * roi检查
     * @throws Throwable
     */
    public function RoiInspection()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->RoiInspection($params);
    }
    /**
     * ads_archive
     * @throws Throwable
     */
    public function get_fb_ads_archive()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->get_fb_ads_archive($params);
    }

    /**
     * 测试广告明细
     * @throws Throwable
     */
    public function GetFacebookAdCampaigns()
    {
        $params     = $this->request->get();
        $params = $params['id'] ?? 0;
        $ApiAdvLogic = new ApiAdvLogic();
        $return = $ApiAdvLogic->GetFacebookAdCampaigns($params);
        halt($return);
        
    }

    /**
     * Adsets
     * @throws Throwable
     */
    public function GetFacebookAdsets()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetFacebookAdsets($params);
    }

    /**
     * Adsets
     * @throws Throwable
     */
    public function GetFacebookAdActivity()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetFacebookAdActivity($params);
    }

    /**
     * Adsets
     * @throws Throwable
     */
    public function GetFacebookCampaignInfo()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetFacebookCampaignInfo($params);
    }

    /**
     * Adsets
     * @throws Throwable
     */
    public function GetFacebookReport()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetFacebookReport($params);
    }


    /**
     * Adsets
     * @throws Throwable
     */
    public function GetAdCreativesList()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetAdCreativesList($params);
    }

    /**
     * Business
     * @throws Throwable
     */
    public function GetAdBusinessInfo()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetAdBusinessInfo($params);
    }


    /**
     * GetAdAccounts
     * @throws Throwable
     */
    public function GetAdAccounts()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetAdAccounts($params);
    }

    /**
     * CampaignsList
     * @throws Throwable
     */
    public function GetAdCampaignsList()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetAdCampaignsList($params);
    }

    /**
     * GetAdsetsList
     * @throws Throwable
     */
    public function GetAdsetsList()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetAdsetsList($params);
    }

    /**
     * GetCreativesList
     * @throws Throwable
     */
    public function GetCreativesList()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetCreativesList($params);
    }

    /**
     * GetAdsList
     * @throws Throwable
     */
    public function GetAdsList()
    {
        $params     = $this->request->get();
        $ApiAdvLogic = new ApiAdvLogic();
        return $ApiAdvLogic->GetAdsList($params);
    }
    //广告账户下的广告系列列表
    //https://shopify.fan-zhou.com/api/ApiAdv/GetAdCampaignsList?id=1069329375092229
    //广告系列下的广告组
    //https://shopify.fan-zhou.com/api/ApiAdv/GetAdsetsList?id=120225362845020601
    //广告组下的广告
    //https://shopify.fan-zhou.com/api/ApiAdv/GetAdsList?id=120225411219430601
    //系列花费
    //https://shopify.fan-zhou.com/api/ApiAdv/GetFacebookReport?id=120224681531650601&date_start=2025-05-01&date_end=2025-05-21
    //广告账户花费
    //https://shopify.fan-zhou.com/api/ApiAdv/GetFacebookReport?id=act_1069329375092229&date_start=2025-05-01&date_end=2025-05-21
    //查详情
    //https://shopify.fan-zhou.com/api/ApiAdv/GetFacebookAdCampaigns?id=120226171471270633

}
